class MissaosController < ApplicationController
  # GET /missaos
  # GET /missaos.xml
  def index
    @missaos = Missao.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @missaos }
    end
  end
  

  # GET /missaos/1
  # GET /missaos/1.xml
  def show
    @missao = Missao.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @missao }
    end
  end

  # GET /missaos/new
  # GET /missaos/new.xml
  def new
    @missao = Missao.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @missao }
    end
  end
  def newNivel
    @nivel = Nivel.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @nivel }
    end
  end
  
  # GET /missaos/1/edit
  def edit
    @missao = Missao.find(params[:id])
  end

  # POST /missaos
  # POST /missaos.xml
  def create
    @missao = Missao.new(params[:missao])

    respond_to do |format|
      if @missao.save
        format.html { redirect_to(@missao, :notice => 'Missao criada com sucesso.') }
        format.xml  { render :xml => @missao, :status => :created, :location => @missao }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @missao.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /missaos/1
  # PUT /missaos/1.xml
  def update
    @missao = Missao.find(params[:id])

    respond_to do |format|
      if @missao.update_attributes(params[:missao])
        format.html { redirect_to(@missao, :notice => 'Missao atualizada com sucesso.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @missao.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /missaos/1
  # DELETE /missaos/1.xml
  def destroy
    @missao = Missao.find(params[:id])
    @missao.destroy

    respond_to do |format|
      format.html { redirect_to(missaos_url) }
      format.xml  { head :ok }
    end
  end
 end 
 